55

Explore Your Deductive Logic—Sudoku

55

STEP 15 continued

                  Call addtocantbelist(putnumber, Mid(putnumberpresent(i, j), 2,

1), kk)

                End If

              Next kk

            End If

          Next k

        End If

      Next j

    Next i

:

Next putnumber

Now that we have looked at the rectangle by scanning columns, the same needs to

be done by scanning rows, as the results of the two scans can be different.

The following codes provide the two steps needed to complete this scan.

STEP 16

The first step is to identify the corners of the rectangle and store them in an array.

This array is called putnumberpresent below. The entire row is scanned for a

candidate number (putnumber) and if the row contains exactly two cells that could

be a home for this number, this row is remembered along with the two columns that

could potentially be the two corners of the rectangle.

‘ algorithm for golden triangle continued

‘ Now Check each row and build putnumberpresent

For putnumber =​ 1 To 9

For i =​ 1 To 9

    For j =​ 1 To 9

      putnumberpresent(i, j) =​ ““

    Next j

Next i

For i =​ 1 To 9

    RowCount =​ 0

    putnumberpresent(i, 1) =​ ““

    lastcorner =​ ““

    For j =​ 1 To 9

    If sbox(i, j) =​ ““ Then

    If findincantbelist(putnumber, i, j) =​ 0 Then

      lastcorner =​ lastcorner & j

      putnumberpresent(i, j) =​ lastcorner

      RowCount =​ RowCount +​ 1

    End If

    End If

Next j

If RowCount =​ 2 Then

Else

    putnumberpresent(i, 1) =​ “*”

End If

Next i

:

: